public class test04 {
    class Solution {
        public int maxSubArray(int[] nums) {
            int sum = Integer.MIN_VALUE;
            int tmp = 0;

            for(int i = 0;i<nums.length;i++){
                tmp += nums[i];
                sum = Math.max(sum,tmp);

                if(tmp<0){
                    //重置
                    tmp = 0;
                }

            }

            return sum;

        }
    }
}
